package com.speljohan.rsbot.script.wrappers;

import com.speljohan.rsbot.accessors.ObjectDef;
import com.speljohan.rsbot.bot.Bot;
import com.speljohan.rsbot.script.Calculations;

public class RSObject {
	long uid;

	public RSObject(final long uid) {
		this.uid = uid;
	}

	public RSObjectDef getDef() {
		return new RSObjectDef((ObjectDef) Calculations.findNodeByID(getID()));
	}

	public int getID() {
		return (int) (uid >>> 32) & 0x7fffffff;
	}

	public RSTile getLocation() {
		return new RSTile((int) (Bot.getClient().getBaseX() + (uid & 0x7f)),
				(int) (Bot.getClient().getBaseY() + (uid >> 7 & 0x7f)));
	}

	/**
	 * type is a one-digit integer 0 - object player 1 - object npc 2 - object
	 * which doesn't move (rock, tree) 3 - object item
	 */
	public int getType() {
		return (int) (uid >> 29) & 0x3;
	}

}
